package main

import "fmt"

/*
123 => 124
129 => 130
199 => 200
999 => 1000

*/

func plusOne(digits []int) []int {
	for i := len(digits) - 1; i >= 0; i-- {
		if digits[i] == 9 {
			digits[i] = 0
		} else {
			digits[i]++
			return digits
		}
	}

	return append([]int{1}, digits...)
}

func main() {
	fmt.Println(plusOne([]int{9, 9, 9}))
}
